<?php
function minNumberInRotateArray($arr)
{
    $left=0;
    $size=count($arr);
    $right=$size-1;
    $mid=$left+intval(($right-$left)/2);
    while($arr[$left]>=$arr[$right]){
        if(($right-$left)==1){
            $mid=$right;
            break;
        }
        $mid=$left+intval(($right-$left)/2);
        if($arr[$left]<=$arr[$mid]){
            $left=$mid;
        }else{
            $right=$mid;
        }
    }
    return $arr[$mid];
}

$arr=array(3,4,5,1,2);
$m=minNumberInRotateArray($arr);
echo $m;